import { Controller, Get, Post, Put, Body, Query, Param, Delete } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { RequirePermission } from 'src/common/decorators/require-premission.decorator';
import { FeedbackService } from './feedback.service';
import { CreateFeedbackDto, BaseFeedbackDto, UpdateFeedbackDto, QueryFeedbackDto, ListFeedbackDto } from './dto/feedback.dto';
import { ApiDataResponse } from 'src/common/decorators/apiDataResponse.decorator';

@ApiTags('用户反馈表，存储用户提交的各类反馈信息')
@Controller('system/feedback')
export class FeedbackController {
  constructor(private readonly feedbackService: FeedbackService) {}

  @ApiOperation({ summary: '用户反馈表，存储用户提交的各类反馈信息-创建' })
  @ApiDataResponse(BaseFeedbackDto)
  // @RequirePermission('system:feedback:add')
  @Post()
  create(@Body() body: CreateFeedbackDto) {
    return this.feedbackService.create(body);
  }

  @ApiOperation({ summary: '用户反馈表，存储用户提交的各类反馈信息-列表' })
  @ApiDataResponse(ListFeedbackDto, true, true)
  // @RequirePermission('system:feedback:list')
  @Get('list')
  findAll(@Query() query: QueryFeedbackDto) {
    return this.feedbackService.findAll(query);
  }

  @ApiOperation({ summary: '用户反馈表，存储用户提交的各类反馈信息-详情' })
  @ApiDataResponse(BaseFeedbackDto)
  // @RequirePermission('system:feedback:query')
  @Get(':id')
  findOne(@Param('id') id: number) {
    return this.feedbackService.findOne(id);
  }

  @ApiOperation({ summary: '用户反馈表，存储用户提交的各类反馈信息-修改' })
  @ApiDataResponse()
  // @RequirePermission('system:feedback:edit')
  @Put()
  update(@Body() body: UpdateFeedbackDto) {
    return this.feedbackService.update(body);
  }

  @ApiOperation({ summary: '用户反馈表，存储用户提交的各类反馈信息-删除' })
  @ApiDataResponse()
  // @RequirePermission('system:feedback:remove')
  @Delete(':id')
  remove(@Param('id') id: string) {
    const ids = id.split(',').map((id) => +id);
    return this.feedbackService.remove(ids);
  }
}
